const pagePermissionMixin = {
  data() {
    return {
      // 当前页面权限
      permiList: [],
      menuCode: '',
    };
  },
  methods: {
    // 获取当页权限
    getPagePermis() {
      let allMenu = JSON.parse(localStorage.getItem('allMenu'));
      let name = this.$route.name;
      this.pagePermission(name, allMenu);
      // console.log('permiList', this.permiList)
    },
    pagePermission(name, allMenu) {
      allMenu = Array.from(allMenu)
      allMenu.forEach((item) => {
        if (item.name == name) {
          this.permiList = item.sysFunc;
          this.menuCode = item.menuCode;
        } else if (item.children && item.children.length > 0) {
          item.children = Array.from(item.children);
          this.pagePermission(name, item.children);
        }
      });
    },
  },
}

export {
  pagePermissionMixin
}